package com.example.service.Imp;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.common.b_pojo.BMenu;
import com.example.dao.mapper.BMenuMapper;
import com.example.service.bMuneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class bMuneServiceImp implements bMuneService {

    @Autowired
    private BMenuMapper bMenuMapper;

    @Override
    public Page<BMenu> getAllmenu(int pageNum, int pageSize) {
        Page<BMenu> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<BMenu> wapper = new LambdaQueryWrapper<>();
        Page<BMenu> bMenuList=bMenuMapper.getAllmenu(page, wapper);
        return bMenuList;
    }

    @Override
    public Page<BMenu> gethasdelectmenu(int pageNum, int pageSize) {
        Page<BMenu> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<BMenu> wapper = new LambdaQueryWrapper<>();
        Page<BMenu> bMenuPage = bMenuMapper.selectPage(page, wapper);
        return bMenuPage;
    }

    @Override
    public BMenu getMenu(Long id) {
        BMenu menu = bMenuMapper.selectById(id);
        return menu;
    }

    @Override
    public boolean startandstopmenu(Long id) {
        return bMenuMapper.startandstopmenu(id) > 0;
    }

    @Override
    public boolean addmenu(BMenu bMenu) {
        int insert = bMenuMapper.insert(bMenu);
        if (insert > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean updatemenu(BMenu bMenu) {
        int update = bMenuMapper.updateById(bMenu);
        if (update > 0) {
            return true;
        }
        return false;
    }

    @Override
    public boolean deletemenu(Long id) {
        int delete = bMenuMapper.deletemenuById(id);
        if (delete > 0) {
            return true;
        }
        return false;
    }

}
